#ifndef __SOCKET_H_INCLUDED
#define __SOCKET_H_INCLUDED

#include <winsock.h>
#include <stdio.h>

/*
 * Number of colors initialized in WinsockStart
 */
#define COLORCOUNT		3

struct socketType
{
	SOCKET s;			// Socket
	char *szUserID;		// Null-Terminated string containing user ID
	COLORREF crText;	// RGB-Packed color for user ID
};

socketType *sockets = NULL;
COLORREF *colors = NULL;
int nCurrentColor = 0;

BOOL WinsockStart(int nSockets);
BOOL WinsockEnd(int nMaxUsers);
BOOL WinsockOpen();
BOOL WinsockClose(int nMaxUsers, SOCKET s = NULL);
void WinsockError(int nSocketError, const char *szFunction);
BOOL WinsockListen(HWND hWnd, int nPort, char *szUserID);
BOOL WinsockAccept(int nMaxUsers);
BOOL WinsockConnect(HWND hWnd, SOCKADDR_IN *serverInfo, char *userID);
BOOL WinsockReadType(SOCKET s, char *szType);
BOOL WinsockSend(const char *text, SOCKET s);
BOOL WinsockReadData(SOCKET s, char **data);
BOOL WinsockSetUser(SOCKET s, int nMaxUsers, char *szUserID);
BOOL WinsockGetUser(SOCKET s, int nMaxUsers, char **szUserID, COLORREF *crText);
BOOL WinsockSetColor(SOCKET s, int nMaxUsers, COLORREF color);
BOOL WinsockBroadcast(int nMaxUsers);
BOOL WinsockSendAll(const char *szSend, int nMaxUsers);
BOOL WinsockGetColor(const char *szName, int nMaxUsers, COLORREF *color);

extern BOOL ChatSend(const char *szCMD, const char *szData, SOCKET s = NULL);

#endif